<?php
$errorFlag = false;
$criteria = new CDbCriteria();
$criteria->condition = "dispatch = '$model->dispatch'";
$criteria->order = 'counter Desc';
$tech = Dispatchtech::model()->find($criteria);
if (empty($tech)) {
    $errorFlag = true;
} else {
    $employee = Employees::model()->findByPk($tech->empno);
    if (empty($employee)) $errorFlag = true;
}

?>
<?php
if ($errorFlag):
    ?>
<h2>No Data Found</h2>
<?php
else:
    ?>

<div class="form">

    <div class="row">


        <div class="model-data">
            <img alt="image" src="/images/content/<?=$employee->image;?>"/>
        </div>

    </div>
    <div class="row">
        <?php echo CHtml::label('Name', '') ?>


        <div class="model-data">
            <?php echo "$employee->firstname $employee->lastname" ?>
        </div>

    </div>
    <div class="row">
        <?php echo CHtml::label('Company Cell Phone', '') ?>


        <div class="model-data">
            <?php echo $employee->workcell; ?>
        </div>

    </div>
    <div class="row">
        <?php echo CHtml::label('Dispatch status', '') ?>


        <div class="model-data">
            <?php

            var_dump($model->complete);
            if (is_null($model->complete)) {
                echo 'Open';
            } else {
                echo 'Close';
            }
            ?>
        </div>

    </div>


</div>
<?php
endif;
?>